﻿using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;

namespace WebUpdaterAdminCore.Data.Migrations
{
    public partial class modify_20180503_1 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ClientStatus_ClientInfos_ClientId",
                table: "ClientStatus");

            migrationBuilder.DropUniqueConstraint(
                name: "AK_ClientStatus_SessionId",
                table: "ClientStatus");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientStatus",
                table: "ClientStatus");

            migrationBuilder.DropIndex(
                name: "IX_ClientStatus_ClientId",
                table: "ClientStatus");

            migrationBuilder.DropColumn(
                name: "ClientId",
                table: "ClientStatus");

            migrationBuilder.DropColumn(
                name: "SessionId",
                table: "ClientStatus");

            migrationBuilder.AddColumn<string>(
                name: "Id",
                table: "ClientStatus",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<string>(
                name: "ClientStatusId",
                table: "ClientInfos",
                nullable: true);

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientStatus",
                table: "ClientStatus",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_ClientInfos_ClientStatusId",
                table: "ClientInfos",
                column: "ClientStatusId");

            migrationBuilder.AddForeignKey(
                name: "FK_ClientInfos_ClientStatus_ClientStatusId",
                table: "ClientInfos",
                column: "ClientStatusId",
                principalTable: "ClientStatus",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ClientInfos_ClientStatus_ClientStatusId",
                table: "ClientInfos");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ClientStatus",
                table: "ClientStatus");

            migrationBuilder.DropIndex(
                name: "IX_ClientInfos_ClientStatusId",
                table: "ClientInfos");

            migrationBuilder.DropColumn(
                name: "Id",
                table: "ClientStatus");

            migrationBuilder.DropColumn(
                name: "ClientStatusId",
                table: "ClientInfos");

            migrationBuilder.AddColumn<string>(
                name: "ClientId",
                table: "ClientStatus",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<string>(
                name: "SessionId",
                table: "ClientStatus",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddUniqueConstraint(
                name: "AK_ClientStatus_SessionId",
                table: "ClientStatus",
                column: "SessionId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ClientStatus",
                table: "ClientStatus",
                columns: new[] { "ClientId", "SessionId" });

            migrationBuilder.CreateIndex(
                name: "IX_ClientStatus_ClientId",
                table: "ClientStatus",
                column: "ClientId",
                unique: true);

            migrationBuilder.AddForeignKey(
                name: "FK_ClientStatus_ClientInfos_ClientId",
                table: "ClientStatus",
                column: "ClientId",
                principalTable: "ClientInfos",
                principalColumn: "ClientId",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
